//
//  ZCSingerContentViewController.m
//  VoiceMusic
//
//  Created by dllo on 15/10/22.
//  Copyright © 2015年 zhangdeyu. All rights reserved.
//

#import "ZCSingerContentViewController.h"
#import "ZCAFNetWork.h"
#import <UIImageView+WebCache.h>
#import "ZCSigerModel.h"
#import <Masonry.h>
#import "ZCSingerContentTableViewCell.h"
#import "ZCSingerMusicModel.h"
#import "ZCSingerAlbumTableViewCell.h"
#import "ZCSingerAlbumModel.h"
#import "ZCSingerMVModel.h"
#import "ZCSingerMVTableViewCell.h"
#import "HeightWithString.h"
#import "ZCAlbumSingerViewController.h"
#import "ZCPlayMusicTool.h"
#import "ZCMVPlayerViewController.h"
#import <MJRefresh.h>
@interface ZCSingerContentViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, assign) BOOL isMusic;
@property (nonatomic, assign) BOOL isAblum;
@property (nonatomic, assign) BOOL isMv;
@property (nonatomic, assign) BOOL isSinger;
@property (nonatomic, copy) NSString *lastStr;
@end

@implementation ZCSingerContentViewController
-(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.isMusic = YES;
        self.isAblum = YES;
        self.isMv = YES;
        self.isSinger = YES;
    }
    return self;
}

- (void)dealloc
{
    self.tableView.delegate = nil;
    self.tableView.dataSource = nil;
    self.ablumTableView.dataSource = nil;
    self.ablumTableView.delegate = nil;
    self.mvTableView.delegate = nil;
    self.mvTableView.dataSource = nil;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.count = 2;
    [self.view setBackgroundColor:[UIColor whiteColor]];
    _dataArray = [[NSMutableArray alloc] init];
    _musicArray = [[NSMutableArray alloc] init];
    _albumArray = [[NSMutableArray alloc] init];
    _mvArray = [[NSMutableArray alloc] init];
    _data = [[NSMutableArray alloc] init];
    self.superHeadView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 300)];
    self.superHeadView.clipsToBounds = YES;
    [self.superHeadView setBackgroundColor:[UIColor clearColor]];
    [self.view addSubview:self.superHeadView];
    
    self.imageView = [[UIImageView alloc] init];
    [self.superHeadView addSubview:self.imageView];
    [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self.superHeadView);
        make.height.equalTo(@(self.view.bounds.size.height / 2 + 150));
    }];
    self.imageView.userInteractionEnabled = YES;
    
    self.headView = [[UIView alloc] init];
    [self.superHeadView addSubview:self.headView];
    [self.headView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self.superHeadView).offset(0);
        make.height.equalTo(@250);
    }];
    self.headView.userInteractionEnabled = YES;
    [self.headView setBackgroundColor:[UIColor blackColor]];
    self.headView.alpha = 0.3;
    
    self.returnButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.superHeadView addSubview:self.returnButton];
    [self.returnButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(self.imageView).offset(20);
        make.height.equalTo(@40);
        make.width.equalTo(@30);
    }];
    [self.returnButton addTarget:self action:@selector(returnButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.returnButton setImage:[UIImage imageNamed:@"fanhui.png"] forState:UIControlStateNormal];
    
    self.nameLable = [[UILabel alloc] initWithFrame:CGRectZero];
    [self.superHeadView addSubview:self.nameLable];
    [self.nameLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.returnButton.mas_bottom).offset(40);
        make.left.equalTo(self.headView).offset(20);
        make.right.equalTo(self.headView).offset(0);
        make.height.equalTo(@40);
    }];
    [self.nameLable setTextColor:[UIColor whiteColor]];
    [self.nameLable setFont:[UIFont boldSystemFontOfSize:26]];
    
    self.concernLable = [[UILabel alloc] initWithFrame:CGRectZero];
    [self.concernLable setTextColor:[UIColor whiteColor]];
    [self.concernLable setFont:[UIFont boldSystemFontOfSize:22]];
    [self.superHeadView addSubview:self.concernLable];
    [self.concernLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.nameLable.mas_bottom).offset(40);
        make.left.equalTo(self.headView).offset(20);
        make.right.equalTo(self.headView).offset(0);
        make.height.equalTo(@30);
    }];
    
    self.buttonView = [[UIView alloc] initWithFrame:CGRectZero];
    self.buttonView.alpha = 0.7;
    [self.buttonView setBackgroundColor:[UIColor blackColor]];
    [self.superHeadView addSubview:self.buttonView];
    [self.buttonView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.headView.mas_bottom).offset(0);
        make.left.right.equalTo(self.superHeadView).offset(0);
        make.bottom.equalTo(self.superHeadView).offset(0);
    }];
    
    self.musicButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.superHeadView addSubview:self.musicButton];
    [self.musicButton setFrame:CGRectZero];
    [self.musicButton mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(self.buttonView.mas_top).offset(0);
    make.bottom.equalTo(self.buttonView).offset(0);
    make.width.equalTo(@(self.view.bounds.size.width / 4));
    make.left.equalTo(self.buttonView).offset(0);
    }];
    [self.musicButton addTarget:self action:@selector(musicButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.musicButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.musicButton setTitleColor:[UIColor orangeColor] forState:UIControlStateSelected];
    

    self.albumButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.albumButton setFrame:CGRectZero];
    [self.albumButton setTitleColor:[UIColor orangeColor] forState:UIControlStateSelected];
    [self.albumButton addTarget:self action:@selector(albumButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.albumButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.albumButton setTitleColor:[UIColor orangeColor] forState:UIControlStateSelected];
    [self.superHeadView addSubview:self.albumButton];
    [self.albumButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.buttonView.mas_top).offset(0);
        make.bottom.equalTo(self.buttonView).offset(0);
        make.width.equalTo(@(self.view.bounds.size.width / 4));
        make.left.equalTo(self.musicButton.mas_right).offset(0);
    }];
    
    self.mvButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.mvButton setFrame:CGRectZero];
    [self.mvButton setTitleColor:[UIColor orangeColor] forState:UIControlStateSelected];
    [self.mvButton addTarget:self action:@selector(mvButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.mvButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.mvButton setTitleColor:[UIColor orangeColor] forState:UIControlStateSelected];
    [self.superHeadView addSubview:self.mvButton];
    [self.mvButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.buttonView.mas_top).offset(0);
        make.bottom.equalTo(self.buttonView).offset(0);
        make.width.equalTo(@(self.view.bounds.size.width / 4));
        make.left.equalTo(self.albumButton.mas_right).offset(0);
    }];
    
    self.contentButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.contentButton setFrame:CGRectZero];
    [self.contentButton setTitleColor:[UIColor orangeColor] forState:UIControlStateSelected];
    [self.contentButton addTarget:self action:@selector(contentButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.contentButton setTitleColor:[UIColor orangeColor] forState:UIControlStateSelected];
    [self.superHeadView addSubview:self.contentButton];
    [self.contentButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.buttonView.mas_top).offset(0);
        make.bottom.equalTo(self.buttonView).offset(0);
        make.width.equalTo(@(self.view.bounds.size.width / 4));
        make.left.equalTo(self.mvButton.mas_right).offset(0);
    }];
    [self.contentButton setTitle:@"歌手信息" forState:UIControlStateNormal];
    
    [self musicTableView];
    [self creatNetWork];
    [self creatNetWorkMusic];
    [self creatNetWorkAlbum];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveValuePush:) name:@"tagValue" object:nil];
    
    
}




#pragma mark 单曲列表
- (void)musicTableView
{
    self.tableView = [[UITableView alloc] init];
    [self.view addSubview:self.tableView];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.equalTo(self.view);
        make.bottom.equalTo(self.view.mas_bottom).offset(-49);
    }];
    [self.tableView setDataSource:self];
    [self.tableView setDelegate:self];
    self.tableView.emptyDataSetSource = self;
    self.tableView.emptyDataSetDelegate = self;
//    self.tableView.bounces = NO;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.tableView setBackgroundColor:[UIColor clearColor]];
    self.tableView.rowHeight = 70;
    self.tableView.tableHeaderView = self.superHeadView;
}

#pragma mark 创建专辑视图
- (void)ablumTableViewCreatView
{
    self.ablumTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
    [self.view addSubview:self.ablumTableView];
    [self.ablumTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.equalTo(self.view);
        make.bottom.equalTo(self.view.mas_bottom).offset(-49);
    }];
    [self.ablumTableView setDataSource:self];
    [self.ablumTableView setDelegate:self];
    self.ablumTableView.emptyDataSetDelegate = self;
    self.ablumTableView.emptyDataSetSource = self;
//    self.ablumTableView.bounces = NO;
    self.ablumTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.ablumTableView setBackgroundColor:[UIColor clearColor]];
    self.ablumTableView.tableHeaderView = self.superHeadView;
}

#pragma mark 创建MV
- (void)mvTableViewCreatView
{
    self.mvTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
    [self.view addSubview:self.mvTableView];
    [self.mvTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.equalTo(self.view);
        make.bottom.equalTo(self.view.mas_bottom).offset(-49);
    }];
    [self.mvTableView setDataSource:self];
    [self.mvTableView setDelegate:self];
    self.mvTableView.emptyDataSetDelegate = self;
    self.mvTableView.emptyDataSetSource = self;
//    self.mvTableView.bounces = NO;
    self.mvTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.mvTableView setBackgroundColor:[UIColor clearColor]];
    self.mvTableView.tableHeaderView = self.superHeadView;
}

#pragma mark 创建歌手信息
- (void)singerContentCreatView
{
    self.singerTableView = [[UITableView alloc]  initWithFrame:CGRectZero style:UITableViewStylePlain];
    [self.view addSubview:self.singerTableView];
    [self.singerTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.equalTo(self.view);
        make.bottom.equalTo(self.view.mas_bottom).offset(-49);
    }];
    [self.singerTableView setDataSource:self];
    [self.singerTableView setDelegate:self];
    self.singerTableView.emptyDataSetSource = self;
    self.singerTableView.emptyDataSetDelegate = self;
    self.singerTableView.bounces = NO;
    self.singerTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.singerTableView setBackgroundColor:[UIColor clearColor]];
    self.singerTableView.tableHeaderView = self.superHeadView;
}

#pragma mark 头视图数据解析和歌手信息数据解析
- (void)creatNetWork
{
    NSString *str = [NSString stringWithFormat:@"http://api.dongting.com/song/singer/%@?utdid=U%%2FXnNdXR1gwDAAnICPQYXIEM&detail=true", self.model.singer_id];
    [ZCAFNetWork getUrl:str body:nil result:ZCJSON headerFile:nil success:^(id result) {
        if (result == nil) {
            return;
        }else {
        NSMutableDictionary *data = [result objectForKey:@"data"];
        ZCSigerModel *singer = [[ZCSigerModel alloc] init];
        [singer setValuesForKeysWithDictionary:data];
        [self.imageView sd_setImageWithURL:[NSURL URLWithString:singer.picUrl] placeholderImage:[UIImage imageNamed:@"52"]];
        [self.nameLable setText:singer.name];
        NSString *str = [NSString stringWithFormat:@"关注: %@", singer.followCount];
        [self.concernLable setText:str];
        NSString *strOne = [NSString stringWithFormat:@"单曲(%@)", singer.songsCount];
        [self.musicButton setTitle:strOne forState:UIControlStateNormal];
        NSString *strTwo = [NSString stringWithFormat:@"专辑(%@)", singer.albumsCount];
        [self.albumButton setTitle:strTwo forState:UIControlStateNormal];
        NSString *strThree = [NSString stringWithFormat:@"MV(%@)", singer.videoCount];
        [self.mvButton setTitle:strThree forState:UIControlStateNormal];
        singer.briefHeight = [HeightWithString heightForTextLabel:singer.brief width:self.view.bounds.size.width fondSize:15];
        singer.personalLifeHeight = [HeightWithString heightForTextLabel:singer.personalLife width:self.view.bounds.size.width fondSize:15];
        singer.awardsHeight = [HeightWithString heightForTextLabel:singer.awards width:self.view.bounds.size.width fondSize:15];
        singer.entertainmentExperienceHeight = [HeightWithString heightForTextLabel:singer.entertainmentExperience width:self.view.bounds.size.width fondSize:15];
        singer.earlyExperienceHeight = [HeightWithString heightForTextLabel:singer.earlyExperience width:self.view.bounds.size.width fondSize:15];
        [_dataArray addObject:singer];
        [_singerTableView reloadData];
        }
    } failure:^(NSError *error) {
        
    }];
}

#pragma mark 单曲数据解析
- (void)creatNetWorkMusic
{
    NSString *str = [NSString stringWithFormat:@"http://api.dongting.com/song/singer/%@/songs?s=s200&agent=none&size=30&longitude=0.0&hid=6125550060252570&utdid=UyKT11zHlGYBACzJ72FDxmdxJ&from=android&net=2&app=ttpod&os=5.0.2&v=v8.1.1.2015081120&alf=700159&api_version=1.0&imei=863583022034533&tid=0&latitude=0.0&resolution=720x1280&uid=863583022034533&f=168&language=zh&page=1&user_id=0&imsi=460026046186283", self.model.singer_id];
    [ZCAFNetWork getUrl:str body:nil result:ZCJSON headerFile:nil success:^(id result) {
        NSMutableArray *array = [result objectForKey:@"data"];
        for (NSMutableDictionary *dic in array) {
            ZCSingerMusicModel *singer = [[ZCSingerMusicModel alloc] init];
            [singer setValuesForKeysWithDictionary:dic];
            [_musicArray addObject:singer];
            [_tableView reloadData];
            self.tableView.header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
                [self loadNewData];
            }];
            self.tableView.footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
                [self loadMoreData];
            }];
        }
        [_tableView reloadData];
        }
        failure:^(NSError *error) {
        
    }];
}

#pragma mark 单曲下拉上拉
- (void)loadNewData
{
    _musicArray = [NSMutableArray array];
    NSString *str = [NSString stringWithFormat:@"http://api.dongting.com/song/singer/%@/songs?s=s200&agent=none&size=30&longitude=0.0&hid=6125550060252570&utdid=UyKT11zHlGYBACzJ72FDxmdxJ&from=android&net=2&app=ttpod&os=5.0.2&v=v8.1.1.2015081120&alf=700159&api_version=1.0&imei=863583022034533&tid=0&latitude=0.0&resolution=720x1280&uid=863583022034533&f=168&language=zh&page=1&user_id=0&imsi=460026046186283", self.model.singer_id];
    [ZCAFNetWork getUrl:str body:nil result:ZCJSON headerFile:nil success:^(id result) {
        NSMutableArray *array = [result objectForKey:@"data"];
        for (NSMutableDictionary *dic in array) {
            ZCSingerMusicModel *singer = [[ZCSingerMusicModel alloc] init];
            [singer setValuesForKeysWithDictionary:dic];
            [_musicArray addObject:singer];
            [_tableView reloadData];
            [self.tableView.header endRefreshing];
        }
        [_tableView reloadData];
    }failure:^(NSError *error) {
                    
    }];
}

- (void)loadMoreData
{
    NSString *str = [NSString stringWithFormat:@"http://api.dongting.com/song/singer/%@/songs?s=s200&agent=none&size=30&longitude=0.0&hid=6125550060252570&utdid=UyKT11zHlGYBACzJ72FDxmdxJ&from=android&net=2&app=ttpod&os=5.0.2&v=v8.1.1.2015081120&alf=700159&api_version=1.0&imei=863583022034533&tid=0&latitude=0.0&resolution=720x1280&uid=863583022034533&f=168&language=zh&page=%ld&user_id=0&imsi=460026046186283", self.model.singer_id, (long)self.count];
    [ZCAFNetWork getUrl:str body:nil result:ZCJSON headerFile:nil success:^(id result) {
        if (result == nil) {
            return;
        }else {
            NSMutableArray *array = [result objectForKey:@"data"];
            for (NSMutableDictionary *dic in array) {
                ZCSingerMusicModel *singer = [[ZCSingerMusicModel alloc] init];
                [singer setValuesForKeysWithDictionary:dic];
                [_musicArray addObject:singer];
                [_tableView reloadData];
            }
            [_tableView reloadData];
        }
    } failure:^(NSError *error) {
        
    }];
    self.count = self.count + 1;
    [self.tableView.footer endRefreshing];
    
}

#pragma mark 专辑数据解析
- (void)creatNetWorkAlbum
{
    NSString *str = [NSString stringWithFormat:@"http://api.dongting.com/song/singer/%@/albums?utdid=UyKT11zHlGYBACzJ72FDxmdxJ&size=10&page=1", self.model.singer_id];
    [ZCAFNetWork getUrl:str body:nil result:ZCJSON headerFile:nil success:^(id result) {
        if (result == nil) {
            return;
        }else {
        self.data = [result objectForKey:@"data"];
        for (NSMutableDictionary *dic in self.data) {
            ZCSingerAlbumModel *singer = [[ZCSingerAlbumModel alloc] init];
            [singer setValuesForKeysWithDictionary:dic];
            [_albumArray addObject:singer];
            [_ablumTableView reloadData];
            
        }
        }
    } failure:^(NSError *error) {
        
    }];
}

#pragma mark MV数据解析
- (void)creatNetWorkMV
{
    NSString *str = [NSString stringWithFormat:@"http://api.dongting.com/song/singer/%@/videos?utdid=UyKT11zHlGYBACzJ72FDxmdxJ&size=50&page=1", self.model.singer_id];
    [ZCAFNetWork getUrl:str body:nil result:ZCJSON headerFile:nil success:^(id result) {
//        if (result == nil) {
//            return;
//        }else {
        NSMutableArray *array = [result objectForKey:@"data"];
        for (NSMutableDictionary *dic in array) {
            ZCSingerMVModel *singer = [[ZCSingerMVModel alloc] init];
            [singer setValuesForKeysWithDictionary:dic];
            [_mvArray addObject:singer];
            [_mvTableView reloadData];
            self.mvTableView.header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
                [self loadNewDataMV];
            }];
            self.mvTableView.footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
                [self loadMoreDataMV];
            }];
//        }
        }
        [_mvTableView reloadData];
    } failure:^(NSError *error) {
        
    }];
}

#pragma mark MV下拉上拉

- (void)loadNewDataMV
{
    _mvArray = [NSMutableArray array];
    NSString *str = [NSString stringWithFormat:@"http://api.dongting.com/song/singer/%@/videos?utdid=UyKT11zHlGYBACzJ72FDxmdxJ&size=50&page=1", self.model.singer_id];
    [ZCAFNetWork getUrl:str body:nil result:ZCJSON headerFile:nil success:^(id result) {
        //        if (result == nil) {
        //            return;
        //        }else {
        NSMutableArray *array = [result objectForKey:@"data"];
        for (NSMutableDictionary *dic in array) {
            ZCSingerMVModel *singer = [[ZCSingerMVModel alloc] init];
            [singer setValuesForKeysWithDictionary:dic];
            [_mvArray addObject:singer];
            [_mvTableView reloadData];
            [self.mvTableView.header endRefreshing];
            //        }
        }
        [_mvTableView reloadData];
    } failure:^(NSError *error) {
        
    }];
}

- (void)loadMoreDataMV
{
    NSString *str = [NSString stringWithFormat:@"http://api.dongting.com/song/singer/%@/videos?utdid=UyKT11zHlGYBACzJ72FDxmdxJ&size=50&page=%ld", self.model.singer_id, (long)self.count];
    [ZCAFNetWork getUrl:str body:nil result:ZCJSON headerFile:nil success:^(id result) {
        //        if (result == nil) {
        //            return;
        //        }else {
        NSMutableArray *array = [result objectForKey:@"data"];
        for (NSMutableDictionary *dic in array) {
            ZCSingerMVModel *singer = [[ZCSingerMVModel alloc] init];
            [singer setValuesForKeysWithDictionary:dic];
            [_mvArray addObject:singer];
            [_mvTableView reloadData];

            //        }
        }
        [_mvTableView reloadData];
    } failure:^(NSError *error) {
        
    }];
    self.count = self.count + 1;
    [self.mvTableView.footer endRefreshing];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView == self.tableView) {
        return 70;
    }else if (tableView == self.ablumTableView) {
        NSInteger i = self.data.count;
        return (i / 2) * 170;
    }else if (tableView == self.mvTableView) {
        return 120;
    }else if (tableView == self.singerTableView) {
        if (indexPath.row == 0) {
            ZCSigerModel *pageModel = [_dataArray objectAtIndex:indexPath.row];
            return pageModel.briefHeight + 100;
        }
    }
    return 70;
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    if (tableView == self.tableView) {
        return @"单曲列表";
    }else if (tableView == self.ablumTableView) {
        return @"歌手专辑";
    }else if (tableView == self.mvTableView) {
        return @"歌手MV";
    }else if (tableView == self.singerTableView) {
        return @"歌手详情";
    }
    return @"等待加载...";
}

#pragma mark 单曲tableView
#pragma mark tableView协议
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView == self.tableView) {
        return [_musicArray count];
    } else if (tableView == self.ablumTableView) {
        return 1;
    } else if (tableView == self.mvTableView) {
        return [_mvArray count];
    } else if (tableView == self.singerTableView) {
        return 1;
    }
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView == self.tableView) {
        static NSString * cellID = @"cell";
        ZCSingerContentTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellID];
        if (cell == NO) {
            cell = [[ZCSingerContentTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellID];
            
        }
        if (_musicArray.count > 0) {
            ZCSingerMusicModel *pageModel = [_musicArray objectAtIndex:indexPath.row];
            [cell getInfo:pageModel];
        }
        return cell;
    } else if (tableView == self.ablumTableView) {
        static NSString *cellid = @"cellTwo";
        ZCSingerAlbumTableViewCell * cellTwo = [tableView dequeueReusableCellWithIdentifier:cellid];
        if (cellTwo == NO) {
            cellTwo = [[ZCSingerAlbumTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid];
            if (indexPath.section == 0) {
                cellTwo.self.mainArray = self.albumArray;
                [cellTwo.collection reloadData];
            }
        }
        return cellTwo;
    } else if (tableView == self.mvTableView) {
        static NSString *celliD = @"cellThree";
        ZCSingerMVTableViewCell * cellThree = [tableView dequeueReusableCellWithIdentifier:celliD];
        if (cellThree == NO) {
            cellThree = [[ZCSingerMVTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:celliD];
        }
        if (_musicArray.count > 0) {
            ZCSingerMVModel *pageModel = [_mvArray objectAtIndex:indexPath.row];
            [cellThree getInfo:pageModel];
        }
        return cellThree;
    }
    else if (tableView == self.singerTableView) {
        static NSString *cellId = @"cellFour";
        UITableViewCell *cellFour = [tableView dequeueReusableCellWithIdentifier:cellId];
        if (cellFour == NO) {
            cellFour = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
            if (indexPath.row == 0) {
                ZCSigerModel *pageModel = [_dataArray objectAtIndex:indexPath.row];
                [cellFour.textLabel setFont:[UIFont systemFontOfSize:15]];
//                [cellFour.textLabel setFrame:CGRectMake(0, 0, self.view.bounds.size.height, pageModel.briefHeight)];
                cellFour.textLabel.text = pageModel.brief;
                cellFour.textLabel.numberOfLines = 0;
            }
        
        }
        return cellFour;
    }
    return nil;
}

#pragma mark 消除navigationController
- (void)viewWillAppear:(BOOL)animated
{
    [self.navigationController setNavigationBarHidden:YES animated:animated];
    [super viewWillAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
    [self.navigationController setNavigationBarHidden:NO animated:animated];
    [super viewWillAppear:animated];
}
- (void)returnButtonClick:(UIButton *)button
{
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark 头视图Button点击方法
- (void)musicButtonClick:(UIButton *)button
{
    [self.ablumTableView removeFromSuperview];
    [self.superHeadView removeFromSuperview];
    [self.mvTableView removeFromSuperview];
    [self.singerTableView removeFromSuperview];
    [self musicTableView];
    if(self.isMusic){
        [self creatNetWorkMusic];
        [self creatNetWork];
        self.isMusic = NO;
    }else{
        if (self.dataArray.count != 0) {
            [self creatNetWorkMusic];
            [self creatNetWork];
        }
    }
    self.musicButton.selected = YES;
    self.albumButton.selected = NO;
    self.contentButton.selected = NO;
    self.mvButton.selected = NO;
}

- (void)albumButtonClick:(UIButton *)button
{
    [self.tableView removeFromSuperview];
    [self.superHeadView removeFromSuperview];
    [self.mvTableView removeFromSuperview];
    [self.singerTableView removeFromSuperview];
    [self ablumTableViewCreatView];
    if(self.isAblum){
        [self creatNetWorkAlbum];
        [self creatNetWork];
        self.isAblum = NO;
    }else{
        if (self.albumArray.count != 0) {
            [self creatNetWork];
            [self creatNetWorkAlbum];
        }
    }
    self.musicButton.selected = NO;
    self.albumButton.selected = YES;
    self.contentButton.selected = NO;
    self.mvButton.selected = NO;
}

- (void)mvButtonClick:(UIButton *)button
{
    [self.tableView removeFromSuperview];
    [self.superHeadView removeFromSuperview];
    [self.ablumTableView removeFromSuperview];
    [self.singerTableView removeFromSuperview];
    [self mvTableViewCreatView];
    if(self.isMv){
        [self creatNetWorkMV];
        [self creatNetWork];
        self.isMv = NO;
    }else{
        if (self.mvArray.count != 0) {
            [self creatNetWork];
            [self creatNetWorkMV];
        }
    }
    self.musicButton.selected = NO;
    self.albumButton.selected = NO;
    self.contentButton.selected = NO;
    self.mvButton.selected = YES;
}

- (void)contentButtonClick:(UIButton *)button
{
    [self.tableView removeFromSuperview];
    [self.superHeadView removeFromSuperview];
    [self.ablumTableView removeFromSuperview];
    [self.mvTableView removeFromSuperview];
    [self singerContentCreatView];
    if(self.isSinger){
        [self creatNetWork];
        [self creatNetWork];
        self.isSinger = NO;
    }else{
        if (self.dataArray.count != 0) {
            [self creatNetWork];
            [self creatNetWork];
        }
    }
    self.musicButton.selected = NO;
    self.albumButton.selected = NO;
    self.contentButton.selected = YES;
    self.mvButton.selected = NO;
}


-(void)receiveValuePush:(NSNotification *)notification
{
    ZCAlbumSingerViewController *album = [[ZCAlbumSingerViewController alloc] init];
    album.str = notification.userInfo[@"albumId"];
    [self.navigationController pushViewController:album animated:YES];
}

#pragma mark 点击方法
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView == self.tableView) {
        ZCSingerMusicModel *model = [_musicArray objectAtIndex:indexPath.row];
        if(model.mvList.count == 0) {
            
            UIAlertController *alter = [UIAlertController alertControllerWithTitle:@"消息" message:@"版权不支持" preferredStyle:UIAlertControllerStyleAlert];
            [self presentViewController:alter animated:YES completion:nil];
            
            [self dismissViewControllerAnimated:YES completion:^{
            }];
            return;
        }
        
        //判断歌曲是否重复点击
        if([self.lastStr isEqualToString:model.auditionList[0][@"url"]])return;
        
        self.lastStr = model.auditionList[0][@"url"];
        
        NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:model.name,@"name",model.singerName,@"nameSinge",model.mvList[0][@"picUrl"],@"heat",model.auditionList[0][@"url"],@"url",nil];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"play" object:self userInfo:dic];
        
        [[NSUserDefaults standardUserDefaults] setObject:model.auditionList[0][@"url"] forKey:@"url"];
        //播放音乐
        [ZCPlayMusicTool getPlay:model.auditionList[0][@"url"]];
        [ZCPlayMusicTool sharePlay].urlMusic = model.auditionList[0][@"url"];
        //发送监听列表的属性
        NSDictionary *arrDic = [NSDictionary dictionaryWithObjectsAndKeys:self.musicArray,@"arr", nil];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"arr" object:nil userInfo:arrDic];
        
        [ZCPlayMusicTool sharePlay].pross = @"0";
        
    }else if (tableView == self.mvTableView)
    {
        ZCSingerMVModel *model = [_mvArray objectAtIndex:indexPath.row];
        ZCMVPlayerViewController *MVVC = [[ZCMVPlayerViewController alloc] init];
        MVVC.MVurl = model.mvList[0][@"url"];
        MVVC.myId = model.uId;
        MVVC.singerName = model.singerName;
        MVVC.videoName = model.videoName;
        MVVC.introduce = model.desc;
        
        UIWindow *window = [[UIApplication sharedApplication].windows firstObject];
        UIView *view= (UIView *) [window.rootViewController.view viewWithTag:9999];
        view.hidden = YES;
        [self.navigationController pushViewController:MVVC animated:YES];
    }
    
}



- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}

*/

@end
